package com.dlust.notestxx.Model;

import androidx.room.Dao;
import androidx.room.Delete;
import androidx.room.Insert;
import androidx.room.OnConflictStrategy;
import androidx.room.Query;
import androidx.room.Update;

import java.util.List;

// Step 2: 编写 DAO 类
@Dao
public interface MainDAO {

    @Insert(onConflict = OnConflictStrategy.REPLACE)
    void  insert(Note note);

    @Query("select * from notes order by id desc")
    List<Note> getAll();

    @Insert(onConflict = OnConflictStrategy.REPLACE)
    long[]  insertAll(Note... notes);

    @Update
    void Update(Note... notes);

    @Query("UPDATE notes SET title = :title, notes = :notes WHERE id= :id")
    void update(int id, String title, String notes);

    @Delete
    void delete(Note note);
}